print("%8d" % (25666))

print(f"年龄{18}")


print(len("fsdfsdf"))

str="123456"
n=0
for x in str:
    n+=1
print(n)


#函数
def my_len(str):
    n=0
    for x in str:
        n += 1
    print(f"{str}字符串长度{n}")
my_len("123456")
my_len("132")
print(my_len("fsdfsd"))


def my_add(x,y):
    n=x+y;
    print(f"{x}+{y}={n}")

my_add(1,2)
my_add(10,2)

#函数注释
def my_mul(x,y):
    """
    两数相乘
    :param x:参数x
    :param y:参数y
    :return: 结果
    """
    return x*y,"hellw"
a=my_mul(20,5)
print(a)
print(type(a))
print(a[0])
print(a[1])

a,b=my_mul(20,5)
print(a)
print(b)


#函数嵌套
def my_service(x,y):
    print(x)
    my_save("mysql")
    print(y)

def my_save(data):
    print("入库")

my_service(1,3)

print("123fsdf321\t123")
print("1\t\t\t123")

print("====函数参数定义===")
def my_add(x,y,z='男'):
    n=x+y
    print(f"{n} {z}")

my_add(10,20)
my_add(10,20,"女")
my_add(10,20,z="女")

#不定长参数：位置参数
def my_info(*args):
   #接收的参数是元组
   print(args)
my_info("a","b","c")

#不定长参数：关键字参数
def my_info(**kwargs):
   #接收的参数是字典
   print(kwargs)
my_info(name="zheng",age="18")

print("=====函数当做参数传递=====")
def test_func(nmhs,x,y):
    n=nmhs(x,y)
    return n
def nm_func(x,y):
    return x*y;

print(test_func(nm_func, 2, 3))
print(test_func(nm_func, 5, y=3))

print("=====lambada匿名函数=====")
print(test_func(lambda x, y: x * y, 5, 6))






